package com.java2_22_1;

public class PetOwner {
    private String name;
    private int age;

    public PetOwner() {

    }

    public PetOwner(String name, int age) {
        this.name = name;
        this.age = age;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public void keepPet(Animal animal, String something) {
        if (animal instanceof Dog dog) {
            System.out.println("颜色为" + dog.getColor() + "的" + dog.getAge() + "岁的狗，在吃" + something);
        }
        if (animal instanceof Cat cat) {
            System.out.println("颜色为" + cat.getColor() + "的" + cat.getAge() + "岁的猫，在吃" + something);
        }
    }
}
